<?php

use Fisharebest\Webtrees\Http\RequestHandlers\AutoCompleteSurname;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Tree;

/**
 * @var string $ajax_url
 * @var bool   $soundex_dm
 * @var bool   $soundex_std
 * @var string $surname
 * @var string $title
 * @var Tree   $tree
 */

?>

<h2 class="wt-page-title">
    <?= $title ?>
</h2>

<form method="post" class="wt-page-options wt-page-options-branches d-print-none">
    <?= csrf_field() ?>

    <div class="form-group row">
        <label class="col-form-label col-sm-3 wt-page-options-label" for="surname">
            <?= I18N::translate('Surname') ?>
        </label>

        <div class="col-sm-9 wt-page-options-value">
            <input class="form-control" data-autocomplete-url="<?= e(route(AutoCompleteSurname::class, ['tree' => $tree->name()])) ?>" autocomplete="off" type="text" name="surname" id="surname" value="<?= e($surname) ?>" dir="auto" required>
        </div>
    </div>

    <fieldset class="form-group">
        <div class="row">
            <legend class="col-form-label col-sm-3 wt-page-options-label">
                <?= I18N::translate('Phonetic search') ?>
            </legend>

            <div class="col-sm-9 wt-page-options-value">
                <?= view('components/checkbox-inline', ['label' => I18N::translate('Russell'), 'name' => 'soundex_std', 'checked' => $soundex_std]) ?>
                <?= view('components/checkbox-inline', ['label' => I18N::translate('Daitch-Mokotoff'), 'name' => 'soundex_dm', 'checked' => $soundex_dm]) ?>
            </div>
        </div>
    </fieldset>

    <div class="form-group row">
        <div class="col-sm-3 wt-page-options-label"></div>

        <div class="col-sm-9 wt-page-options-value">
            <button type="submit" class="btn btn-primary">
                <?= /* I18N: A button label. */ I18N::translate('view') ?>
            </button>
        </div>
    </div>
</form>

<?php if ($ajax_url !== '') : ?>
    <div class="wt-ajax-load wt-page-content wt-chart wt-branches" data-ajax-url="<?= e($ajax_url) ?>"></div>
<?php endif ?>
